<template>
	<view>
		<uni-popup ref="customPopup" type="center" @touchmove.stop.prevent="moveHandle">
			<view class="popup" :style="{width:width+'rpx' , color: textColor}">
				<view class=" " style="text-align: center;" :style="{fontSize: fontSize +'rpx' }">
					<text>{{title}}</text>
				</view>
				<view class="input">
					<uni-easyinput v-model="searchValue" :placeholder="'请输入'+ title" type="number"
						@input="InputClick($event)"></uni-easyinput>
				</view>
				<view class="button flex jbetween" style="border-top: 1px solid #e9e9e9;margin-top: 30rpx;">
					<view class="left"
						style="color: #000;font-size: 30rpx;flex: 5;border-right: 1px solid #e9e9e9;text-align: center;padding: 10px 0 10px 0;"
						@click="close">{{ cancelText}}</view>
					<view class="right" style="color: blue;font-size: 30rpx;flex:5;text-align: center;padding: 10px 0 10px 0;"
						@click="submit">{{confirmText}}</view>
				</view>
			</view>
		</uni-popup>

	</view>
</template>

<script>
	import {
		BaseProjectTheDataByDicKey,
	} from "../pages/interface.js"
	//不想双向绑定了
	export default {
		props: {
			width: { //彈窗的寬度
				type: [Number, String],
				default: 600
			},
			textColor: { //标题颜色
				type: String,
			},
			fontSize: { //标题字体大小
				type: [Number, String],
				default: 30
			},
			cancelText: { //取消按钮
				type: String,
				default: "取消"
			},
			confirmText: { //确定按钮
				type: String,
				default: "确定"
			},
			parentObj: {
				type: Object
			}
		},
		data() {
			return {
				title: "", //标题
				customType: "", //用于判断当前点击的条件类型
				searchValue: '', //输入的值
			}
		},
		methods: {
			InputClick(event) {
				const inputRule = /[^\d.]/g //只能输入数字和小数
				this.$nextTick(function() {
					this.searchValue = event.replace(inputRule, '');
				})
			},
			moveHandle() {},
			// 搜索
			search(e) {
				let arr = []
				this.data.forEach(item => {
					let newStr = item.NickName + item.Name + item.Phone
					item.newStr = newStr
					if (item.newStr.indexOf(e.value) != -1) {
						arr.push(item)
					}
				})
				this.hobby = arr
			},
			open(entity, type, title) {
				console.log('entity--', entity)
				this.title = title
				this.customType = type
				this.searchValue = "" //清空搜索框
				this.defaultActiveData = "" //清空选中的选项
				this.$refs.customPopup.open() //打开弹窗

			},
			close() {
				this.searchValue = ''
				this.$refs.customPopup.close()
			},
			submit() {
				this.$emit('customSubmit', this.searchValue, this.customType)
				this.$refs.customPopup.close()
			},

		}
	}
</script>

<style scoped lang="scss">
	.popup {
		background: #fff;
		padding: 20rpx 0rpx 0rpx 0rpx;
		border-radius: 10rpx;
	}

	.input {
		margin: 20rpx 20rpx;
	}

	/deep/.checklist-group {
		display: block !important;
		width: 100%;
		height: 40vh;
		padding: 0px 10px 10px 10px;

		box-sizing: border-box;
		text-align: center;
		overflow-y: scroll;
	}

	/deep/.checklist-box {
		display: block !important;
		margin: 5px !important;
	}

	/deep/.checklist-content {

		display: block !important;
	}
</style>